/* MDApplet.java
 * Created on 15-May-2006 by Jordan at 5:25:56 PM
 *
 * Jordan Klassen
 * Block F
 * Info Tech 12: Programming
 * Assignment ?.??.? (insert name here)
 * Due on dd-mm-2006
 * Description:
 * Dependancies:
 */

package mduel;

import java.applet.Applet;
import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import mduel.SpriteBank;

public class MDApplet extends Applet implements MouseListener {
	private static final long serialVersionUID = 1L;
	public GameWin gameWindow = null;
	public static final Rectangle startRect = new Rectangle(320 - 60, 100, 120,
			40), optRect = new Rectangle(320 - 60, 160, 120, 40);
	
	Font MDFont = null;

	public void init() {
		resize(640, 480);
		addMouseListener(this);
		MDFont = SpriteBank.getFont_from_file("marshmallowDuel.ttf", this);
	}

	public void paint(Graphics g) {
		resize(640, 480);
		g.setColor(Color.black);
		g.fillRect(0, 0, 640, 480);
		g.setColor(Color.RED);
		((Graphics2D) g).draw(startRect);
		((Graphics2D) g).draw(optRect);
		g.setFont(MDFont.deriveFont(Font.PLAIN, 64));
		g.drawString("MDuel Java", 320 - g.getFontMetrics().stringWidth(
				"MDuel Java") / 2, 60);
		g.setFont(MDFont.deriveFont(Font.PLAIN, 20));
		g.drawString("Start Game", 640 / 2 - 60 + 7, 126);
		g.drawString("Set Options", 320 - 60 + 8, 126 + 60);
	}

	public void mouseClicked(MouseEvent me) {
		if (startRect.contains(me.getPoint())) {
			System.out.println("Start button");
			if (gameWindow == null)
			{
				gameWindow = new GameWin();
			}
			gameWindow.getWin().setVisible(true);
		}
		if (optRect.contains(me.getPoint())) {
			System.out.println("Option button");
		}
	}

	public void mousePressed(MouseEvent e) {
	}

	public void mouseReleased(MouseEvent e) {
	}

	public void mouseEntered(MouseEvent e) {
	}

	public void mouseExited(MouseEvent e) {
	}
}